[#ftl]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>字典编辑</title>
<link rel="stylesheet" type="text/css" href="${base}/css/date.css" />
<link rel="stylesheet" type="text/css" href="${base}/css/base.css" />
<link rel="stylesheet" type="text/css" href="${base}/css/form.css" />
<link rel="stylesheet" type="text/css" href="${base}/commonjs/ztree/css/zTreeStyle/zTreeStyle.css" />
<link rel="stylesheet" type="text/css" href="${base}/commonjs/artDialog6/ui-dialog.css" />
<link rel="stylesheet" type="text/css" href="${base}/css/pop.css" />


<script type="text/javascript" src="${base}/commonjs/jquery1.7.2/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="${base}/commonjs/jquery-forms.js"></script>
<script type="text/javascript" src="${base}/commonjs/artDialog6/dialog-plus-min.js"></script>
<script type="text/javascript" src="${base}/commonjs/message/message.js"></script>
<script type="text/javascript" src="${base}/commonjs/noty/jquery.noty.packaged.min.js"></script>
<script type="text/javascript" src="${base}/commonjs/jquery-validation/jquery.validate.min.js" ></script>
<script type="text/javascript" src="${base}/commonjs/jquery-validation/localization/messages_zh.js" ></script>
<script type="text/javascript" src="${base}/commonjs/tab/tabs.js"></script>
<script type="text/javascript" src="${base}/commonjs/datatable/js/jquery.dataTables.min.js"></script>
<script type="text/javascript">	
/*$(document).ready(function(){
   
	var dictId=$("#beanId").val();
	var tag=0;
	 var table = $('#itemTable').DataTable( {
	     "language": {
            "infoEmpty": "没有找到任何数据项。",
            "zeroRecords":"没有找到匹配的记录",
            "search": "过滤"
        },
	    "paging":   false,
        "ordering": false,
        "info":     false,
        "filter":   false,
        "ajax":   "allitems/"+dictId,
        "columns": [
        {"data": "name"},
        {"data": "code"},
        {"data": "value"},
        {"data": "showOrder"}
      ],
      "columnDefs": [ {
            "targets": 4,
            "data": null,
            "defaultContent": "<button>Delete</button>"
        } ]      
    } );
    
     $('#itemTable tbody').on( 'click', 'button', function () {      
        table.$('tr.selected').removeClass('selected');
        $(this).parents('tr').addClass('selected');   
        table.row('.selected').remove().draw( false );
    } );
    	
    $('#itemTable tbody').on( 'dblclick', 'tr', function () {
            table.$('tr.selected').removeClass('selected');
            $(this).addClass('selected');
            $("#aname").val($(this).find("td").eq(0).html());
		    $("#acode").val($(this).find("td").eq(1).html());
		    $("#avalue").val($(this).find("td").eq(2).html());
		    $("#ashowOrder").val($(this).find("td").eq(3).html());
            tag=1;
    } ); 
    

//增加一行
    $('#addItem').on( 'click', function () {
	   $("#itemform").validate({
	      errorPlacement: function(error, element) {
	             error.appendTo( element.parent());
	          },
	      rules:{aname:{required: true},
	             acode:{required: true},
	             avalue:{required: true},
	             ashowOrder:{required: true}      
	            },
	      messages:{
	             aname:{required: "请输入名称"},
	             acode:{required: "请输入代码"},
	             avalue:{required: "请输入值"},
	             ashowOrder:{required: "请输入次序"}
	      },
	   });
	   var r=$('#itemform').valid();
	   if(r){
	        var aname=$("#aname").val();
		    var acode=$("#acode").val();
		    var avalue=$("#avalue").val();
		    var ashowOrder=$("#ashowOrder").val();	    
		    if(tag==1){
		    table.row('.selected').remove().draw( false );
		    tag=0;
		    }
	        table.row.add( {
	            "name":aname,
	            "code":acode,
	            "value":avalue,
	            "showOrder":ashowOrder
	       }).draw();
	       $("#aname").val("");
		    $("#acode").val("");
		    $("#avalue").val("");
		    $("#ashowOrder").val("");	
		}          
    } );
      
} );
*/
</script>
</head>
<body>
<!-- 主体开始 -->
<div class="dataForm">
<!--		<div class="eva_content_top">
			<ul id="eva_all">
				<li><a tab="eva_tab1" class="eva_focus" href="javascript:void(0);">基本信息</a></li>
				<li><a tab="eva_tab2" class="white" href="javascript:void(0);">数据项</a></li>
			</ul>
		</div>
-->		
		<div id="eva_tab1" class="eva_tab">
			<form id="dataform" action="add" method="post">
				<div class="content mt10">
				<input  id="beanId" name="id"   type="hidden"  value="${(bean.id)!}"/>
					<dl>
					<dt><span   class="required">*</span>名称</dt>
					<dd>			
					<input  class="required " name="name" id="name"  type="text"   value="${(bean.name)}"/>
					</dd>
					
					<dt><span   class="required">*</span>代码</dt>
					<dd>			
					<input  class="required " name="code" id="code"  type="text"  value="${(bean.code)}"/>
					</dd>

					<dt>数据类型</dt>
					<dd>			
					[@c.select id="datatype"  attributes='class="clear"' datas="common.datatype" value="${(bean.datatype)}"/]
					</dd>
		
					<dt>描述</dt>
					<dd>
						<textarea rows="5" cols="38" id="description" name="description"  >${(bean.description)!""}</textarea>
					</dd>
					<dl>
		
					<div class="clear"></div>
				</div>
				<div class="pop_btn">
					<input type="button" id="butSave" class="btn_1" value="保存"/>
					<input type="button" id="butCancel" class="btn_1" value="取消"/>
			    </div>
			</form>						
		</div>	
		<div id="eva_tab2" class="eva_tab">
		        <form id="itemform" >
				<div class="content mt10">
				<input  id="dictId" name="dictId"   type="hidden"  value="${dictid!''}"/>
					<dl>
					<dt>名称</dt>
					<dd>			
					<input class="aname" name="aname" id="aname"  type="text" />
					</dd>
					
					<dt>代码</dt>
					<dd>			
					<input class="acode"  name="acode" id="acode"  type="text"  />
					</dd>

					<dt>值</dt>
					<dd>
						<input class="avalue"  name="avalue" id="avalue"  type="text"  />
					</dd>
					<dt>次序</dt>
					<dd><input class="ashowOrder"   name="ashowOrder" id="ashowOrder"  type="text"  />
					</dd>
					<div class="clear"></div>
				</div>
				<div class="">
					<input class="submit btn_1" type="submit" id="addItem" value="保存"/>
			    </div>
			</form>
				<div class="userole">
					<dl>							   
					   <table id="itemTable" class="mt10 ml10 item" >
							   <thead>
									<tr >
										<th style="width:150px;">
										名称										
										</th>
										<th style="width:100px;">
										代码										
										</th>
										<th style="width:100px;">
										值								
										</th>	
										<th style="width:100px;">
										次序								
										</th>
										<th >
										操作								
										</th>									
									</tr>
								</thead>
								
							</table>
					</dt>					
					<dl>
				</div>				
		</div>			
</div>
<script type="text/javascript">	
	$(function() {
		var names=[];
		var codes=[];
		var values=[];
		var showOrders=[];
	
	    $("#butSave").click(function(){	
	     var dt= $('#itemTable').DataTable();	
	    $("#itemTable tbody tr").each(function()
		 {
		  names.push($(this).find("td").eq(0).html());
		  codes.push($(this).find("td").eq(1).html());
		  values.push($(this).find("td").eq(2).html());
		  showOrders.push($(this).find("td").eq(3).html());
		 });
			 $("#dataform").submit();			
  		 });

		var v = jQuery("#dataform").validate({
		 submitHandler: function(form) {
			$(form).ajaxSubmit({
			    url:"${base}/system/dictionary/update",
			    data:{"names":names,
			    "codes":codes,
			    "values":values,
			    "showOrders":showOrders
			    },
				success: function(data){  
                        noty({
                          text:extendMessages(data).msg.message,
                          layout:"center",
                          timeout:2000,
                          callback:{
                             afterClose:function(){
                                         window.parent.location.reload(); 
                                        }
                           }
                        });
               }
			});
		}
 });
		$("#butCancel").click(function(){
			window.parent.closeArtDialog();
		});
		
	});

	
</script>

</body>
</html>